package edu.ec.java02.group02.controller;

import edu.ec.java02.group02.domain.ManagerInfo;
import edu.ec.java02.group02.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/backGround")
public class BackLoginController {

    @Autowired
    private ManagerService managerService;

    /**
     * 进入后台登录界面
     * @return
     */
    @RequestMapping("/login")
    public String login(){
        return "/admin-login";
    }

    /**
     * 验证管理员登录信息
     * @param managerInfo
     * @return 成功-进入后台界面 <br>  失败-返回登录界面</>
     */
    @RequestMapping("/adminInLogin")
    public String adminInLogin(ManagerInfo managerInfo){
        if(managerService.login(managerInfo)==true){
            return "/other/welcome-admin";
        }
        return "/admin-login";
    }
}
